package com.crm.config;

/**
 * @author zjd
 * @Title:
 * @Description:
 * @date 2021/4/211:47
 */
public class ApiResultException extends RuntimeException{

    /**
     * 异常信息
     */
    private String errorMsg;
    /**
     * 错误码
     */
    private String code;

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    private ApiResultException(String errorMsg) {
        super(errorMsg);
        this.code = errorMsg.substring(0, 4);
        this.errorMsg = errorMsg.substring(5);
    }

    /**
     * 抛出逻辑异常
     *
     * @param errorMsg
     * @return
     */
    public static ApiResultException le(String errorMsg) {
        return new ApiResultException(errorMsg);
    }

}
